import { api } from "@/utils/api";
import { http } from "@/utils/http";
let url = api.API_BASE;
let url2 = api.API_BASE2;
const apiAddress = {
    login(data:any) { //登录接口
        return http.post(url + `login`, data)
    },
    menus(data:any){
        //获取左侧菜单栏
        return http.get(url+`menus`,data)
    },
    menus2(data:any){
        //获取左侧菜单栏
        return http.get(url2+`system/menus`,data)
    },
    usersList(data:any){
        //用户列表
        return http.get(url+`users`,data)
    },
    changeUserStatus(data:any){
        //users/:uId/state/:type
        return http.put(url+`users/${data.uId}/state/${data.type}`,{})
    },
    addUsers(data:any){
        //添加用户
        return http.post(url + `users`, data)
    },
    getUsersById(data:any){
        //根据id查询用户
        return http.get(url+`users/${data.id}`,{})
    },
    putUsers(data:any){
        //编辑提交用户
        return http.put(url+`users/${data.id}`,data)
    },
    deleteUserById(data:any){
        //根据id删除
        return http.delete(url+`users/${data.id}`,{})
    },
    getRoles(data:any){
        //角色列表
        return http.get(url+`roles`,data)
    },
    setUsersRole(data:any){
        //用户分配角色users/:id/role
        return http.put(url+`users/${data.id}/role`,data)
    },
    getRightsList(data:any){
        //权限列表
        return http.get(url+`rights/${data.type}`,{})
    },
    deleteRoleById(data:any){
        return http.delete(url+`roles/${data.roleId}/rights/${data.rightId}`,{})
    },
    addRoles(data:any){
        //分配权限
        return http.post(url+`roles/${data.roleId}/rights`,data)
    },
}
export { apiAddress }
